<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ include file="/pages/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>广东工业大学招生办后台管理</title>
<link rel="stylesheet" href="${ctx }/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="${ctx }/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="${ctx }/kindeditor/lang/zh_CN.js"></script>

<script>
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="entity.content"]', {
			cssPath : '${ctx}/kindeditor/plugins/code/prettify.css',
				uploadJson :  '${ctx}/kindeditor/jsp/upload_json.jsp',  
				fileManagerJson : '${ctx}/kindeditor/jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						document.forms['article'].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						document.forms['article'].submit();
					});
				}
			});
			prettyPrint();
		});
	function check(){
		var typeCheckbox = document.getElementById("typespec");
		var tagInput = document.getElementById("tagspec");
		var topCheckbox = document.getElementById("toptypespec");
		var topInput = document.getElementById("toptagspec");
		if(typeCheckbox.checked){
			tagInput.value="1";
		}else{
			tagInput.value="0";
		}
		if(topCheckbox.checked){
			topInput.value="1";
		}else{
			topInput.value="0";
		}
		var title = document.getElementsByName("entity.title");
		/* var spec=document.getElementsById("spec");
		if(spec.value==""){
			alert("请输入专题名称！");
			return false;
		} */
		if(title.value==""){
			alert("请输入标题！");
			return false;
		}
		if(editor.isEmpty()){
			alert("请输入内容！");
			return false;
		}
		else true;
	}
</script>

</head>

<body>
<s:if test="type==0">
	<div class="article">
		<form action="special-article-admin!save.action" method="post" name="article" onsubmit="return check()" >
		<input type="hidden" name="type" value="${type}"/>
		<input type="hidden" name="entity.tag" id="tagspec"/>
		<input type="hidden" name="entity.hightop" id="toptagspec"/>
		<s:if test="entity.id!=null">
		 <input type="hidden" name="id" value="${entity.id}"/>
		</s:if>
			<table  style="width:100%;">
			  
				<tr>
					<td>标题：</td>
					<td><input type="text" id="title" style="width:100%" name="entity.title" value="${entity.title}"/></td>
				</tr>
				<tr>
					<td>所放置专题名称：</td>
					 <td>
					<select name="spec_id" style="width:100%">
					<option value="${id }">${special.name }</option>
						<s:iterator value="specialList">
							<option value="${id}">${name}</option>
						</s:iterator>
						</select>
					</td>
				</tr>
				
					<tr><td></td>
					<td>
						<input type="checkbox" id="typespec" <s:if test="entity.tag==1"> checked="checked"</s:if>/>是否放至相关链接导读
						<input type="checkbox" id="toptypespec" <s:if test="entity.hightop==1"> checked="checked"</s:if>/>是否置顶
					</td>
				</tr>
				
				<tr>
					<td>内容：</td>
					<td>
						<textarea name="entity.content" style="width:100%;height:400px;visibility:hidden;">${entity.content }</textarea>
					</td>
				</tr>
				<tr>
					<td></td>
					<td align="right">
						<input type="submit" class="button" style="width:80px;" value="提交"/> 
					</td>
				</tr>
			</table>

		</form>
	</div>
	</s:if>
	
	<s:else>
	<div class="article">
		<form action="special-article-admin!save.action" method="post" name="article" onsubmit="return check()" >
		<input type="hidden" name="type" value="${type}"/>
		 <input type="hidden" name="entity.tag" value="1"/> 
		<s:if test="entity.id!=null">
		<input type="hidden" name="id" value="${entity.id }"/>
		</s:if>
			<table  style="width:100%;">
			 
				<tr>
					<td>标题：</td>
					<td><input type="text" id="title" style="width:100%" name="entity.title" value="${entity.title}"/></td>
				</tr>
				<tr>
					<td>专题名称：</td>
					 <td>
					<select name="spec_id" style="width:100%">
					<option value="${id }">${special.name }</option>
						<s:iterator value="specialList">
							<option value="${id}">${name}</option>
						</s:iterator>
						</select>
				</td>
				</tr>
				<tr>
					<td>内容：</td>
					<td>
						<textarea name="entity.content" style="width:100%;height:400px;visibility:hidden;">${entity.content }</textarea>
					</td>
				</tr>
				<tr>
					<td></td>
					<td align="right">
						<input type="submit" class="button" style="width:80px;" value="提交"/> 
					</td>
				</tr>
			</table>

		</form>
	</div>
	</s:else>
</body>
</html>
